package sm.codec.type;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import sm.util.Util;

public class RC implements Cloneable, Serializable {

	private static final long serialVersionUID = 6008778869249877944L;

	public static final String HEADER = "_RCFM*=";

	private List<Object> values;

	public List<Object> getValues() {
		return values;
	}

	public RC(List<Object> values) {
		this.values = values;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((values == null) ? 0 : values.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RC other = (RC) obj;
		if (values == null) {
			if (other.values != null)
				return false;
		} else if (!values.equals(other.values))
			return false;
		return true;
	}

	@Override
	public Object clone() {
		try {
			RC clonedObj = (RC) super.clone();
			clonedObj.values = new ArrayList<Object>();
			for (Object value : values) {
				clonedObj.values.add(Util.cloneData(value));
			}

			return clonedObj;
		} catch (CloneNotSupportedException e) {
			// this shouldn't happen, since we are Cloneable
			throw new InternalError();
		}
	}

}
